import { Component, OnInit, Input } from '@angular/core'
import { Widget } from '../../model'
import { JsonApiService } from '../../../../core/api/json-api.service'


@Component({
  selector: 'mini-program',
  templateUrl: './mini-program.html',
  styleUrls: ['./mini-program.css']
})
// 小程序人数统计
export class MiniProgram implements OnInit, Widget {
  @Input() componentData: any
  // @Input() auth = trues

  registerCount = {
    data: '', // 数据量
    size: '' // 单位，如亿条
  }

  viewCount = {
    data: '', // 数据量
    size: '' // 单位，如亿条
  }
  loading = false

  constructor(private jsonApiService: JsonApiService) { }
  ngOnInit() {
    this.initData()
  }

  // 微信小程序访问量统计
  initData() {
    this.loading = true
    this.jsonApiService.http('control/station/applet/user/appletUserNumStatistics.html', null, false).subscribe(data => {
      this.loading = false
      if (data.success) {
        this.registerCount = common.numberFormat(data.data.totalUser);
        this.viewCount = common.numberFormat(data.data.totalVisit);
      } else {
        this.jsonApiService.message(data.message);
      }
    })
  }
}
